Add device create and device destroy for an existing domain.
{'op' : 'vbd',
'vbd' : vbd })
+ def xend_domain_device_create(self, id, config):
+ return xend_call(self.domainurl(id),
+ {'op' : 'device_create',
+ 'config' : fileof(config) })
+
+ def xend_domain_device_destroy(self, id, type, idx):
+ return xend_call(self.domainurl(id),
+ {'op' : 'device_destroy',
+ 'type' : type,
+ 'index' : idx })
+
def xend_consoles(self):
return xend_get(self.consoleurl())
@param config: configuration
@return: deferred
"""
+ print 'domain_configure>', id, config
dom = int(id)
dominfo = self.domain_get(dom)
if not dominfo:
"""
# Need a cancel too?
# Don't forget to cancel restart for it.
+ print 'domain_migrate>', id, dst
dom = int(id)
xmigrate = XendMigrate.instance()
- return xmigrate.migrate_begin(dom, dst)
+ val = xmigrate.migrate_begin(dom, dst)
+ print 'domain_migrate<', val
+ return val
def domain_save(self, id, dst, progress=0):
"""Start saving a domain to file.
dom = int(dom)
return xc.atropos_domain_get(dom)
+ def domain_device_create(self, dom, devconfig):
+ dom = int(dom)
+ dominfo = self.domain_get(dom)
+ if not dominfo:
+ raise ValueError("invalid domain:" + str(dom))
+ return dominfo.device_create(devconfig)
+
+
+ def domain_device_destroy(self, dom, type, idx):
+ dom = int(dom)
+ dominfo = self.domain_get(dom)
+ if not dominfo:
+ raise ValueError("invalid domain:" + str(dom))
+ return dominfo.device_destroy(type, idx)
+
def domain_devtype_ls(self, dom, type):
"""Get list of device indexes for a domain.
[['dom', 'int'],
['destination', 'str']])
deferred = fn(req.args, {'dom': self.dom.id})
+ print 'op_migrate>', deferred
deferred.addCallback(self._op_migrate_cb, req)
deferred.addErrback(self._op_migrate_err, req)
return deferred
def _op_migrate_cb(self, info, req):
+ print '_op_migrate_cb>', info, req
#req.setResponseCode(http.ACCEPTED)
host = info.dst_host
port = info.dst_port
dom = info.dst_dom
url = "http://%s:%d/xend/domain/%d" % (host, port, dom)
req.setHeader("Location", url)
+ print '_op_migrate_cb> url=', url
return url
def _op_migrate_err(self, err, req):
+ print '_op_migrate_err>', err, req
req.setResponseCode(http.BAD_REQUEST, "Error: "+ str(err))
return str(err)
-
+
+ def op_device_create(self, op, req):
+ fn = FormFn(self.xd.domain_device_create,
+ [['dom', 'int'],
+ ['config', 'sxpr']])
+ try:
+ d = fn(req.args, {'dom': self.dom.id})
+ d.addErrback(self._op_device_create_err, req)
+ return d
+ except ValueError, ex:
+ return ['err', str(ex)]
+
+ def _op_device_create_err(self, err, req):
+ return ['err', str(err)]
+
+ def op_device_destroy(self, op, req):
+ fn = FormFn(self.xd.domain_device_destroy,
+ [['dom', 'int'],
+ ['type', 'str'],
+ ['index', 'int']])
+ val = fn(req.args, {'dom': self.dom.id})
+ return val
+
def op_pincpu(self, op, req):
fn = FormFn(self.xd.domain_pincpu,
[['dom', 'int'],
return val
def destroy(self):
- PrettyPrint.prettyprint(self.sxpr())
self.controller.send_be_vbd_destroy(self.vdev)
class BlkifController(controller.Controller):
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
- return ':'.join(map(lambda x: "%x" % x, mac))
+ return ':'.join(map(lambda x: "%02x" % x, mac))
def configure_vifs(config_devs, vals):
"""Create the config for virtual network interfaces.